function ResizeTool() {
  THREE.Scene.call(this)

  this.x = new THREE.Scene()
  this.y = new THREE.Scene()
  this.z = new THREE.Scene()

  var pid2 = Math.PI / 2

  this.materialRed = new THREE.MeshBasicMaterial({ color: 0xff0000 })
  this.materialGreen = new THREE.MeshBasicMaterial({ color: 0x00ff00 })
  this.materialBlue = new THREE.MeshBasicMaterial({ color: 0x0000ff })
  this.materialYellow = new THREE.MeshBasicMaterial({ color: 0xffff00 })
  this.materialWhite = new THREE.MeshBasicMaterial({ color: 0xffffff })

  // X
  var geometry = new THREE.CylinderGeometry(0.01, 0.01, 1, 5)
  var mesh = new THREE.Mesh(geometry, this.materialRed)
  mesh.position.set(0, 0.5, 0)
  this.x.add(mesh)
  geometry = new THREE.BoxGeometry(0.1, 0.1, 0.1)
  mesh = new THREE.Mesh(geometry, this.materialRed)
  mesh.position.set(0, 1, 0)
  this.x.add(mesh)
  this.x.rotateOnAxis(new THREE.Vector3(0, 0, 1), -pid2)
  this.x.updateMatrix()

  // Y
  geometry = new THREE.CylinderGeometry(0.01, 0.01, 1, 5)
  mesh = new THREE.Mesh(geometry, this.materialGreen)
  mesh.position.set(0, 0.5, 0)
  this.y.add(mesh)
  geometry = new THREE.BoxGeometry(0.1, 0.1, 0.1)
  mesh = new THREE.Mesh(geometry, this.materialGreen)
  mesh.position.set(0, 1, 0)
  this.y.add(mesh)

  // Z
  geometry = new THREE.CylinderGeometry(0.01, 0.01, 1, 5)
  mesh = new THREE.Mesh(geometry, this.materialBlue)
  mesh.position.set(0, 0.5, 0)
  this.z.add(mesh)
  geometry = new THREE.BoxGeometry(0.1, 0.1, 0.1)
  mesh = new THREE.Mesh(geometry, this.materialBlue)
  mesh.position.set(0, 1, 0)
  this.z.add(mesh)
  this.z.rotateOnAxis(new THREE.Vector3(1, 0, 0), pid2)
  this.z.updateMatrix()

  // Center
  geometry = new THREE.BoxGeometry(0.2, 0.2, 0.2)
  this.block = new THREE.Mesh(geometry, this.materialYellow)

  // Add to super
  this.add(this.x)
  this.add(this.y)
  this.add(this.z)

  this.x.updateMatrix()
  this.x.matrixAutoUpdate = false
  this.y.updateMatrix()
  this.y.matrixAutoUpdate = false
  this.z.updateMatrix()
  this.z.matrixAutoUpdate = false

  this.add(this.block)
}

ResizeTool.prototype = Object.create(THREE.Scene.prototype)
ResizeTool.prototype.highlightSelectedComponents = highlightSelectedComponents

function highlightSelectedComponents(raycaster) {

  var selected = false
  var x = false, y = false, z = false, w = false

  if(raycaster.intersectObject(this.x, true).length > 0) {
   selected = true
    x = true
   this.x.children[0].material = this.materialYellow
   this.x.children[1].material = this.materialYellow
  } else {
   this.x.children[0].material = this.materialRed
   this.x.children[1].material = this.materialRed
  }

  if(raycaster.intersectObject(this.y, true).length > 0) {
   selected = true
   y = true
   this.y.children[0].material = this.materialYellow
   this.y.children[1].material = this.materialYellow
  } else {
   this.y.children[0].material = this.materialGreen
   this.y.children[1].material = this.materialGreen
  }

  if(raycaster.intersectObject(this.z, true).length > 0) {
   selected = true
   z = true
   this.z.children[0].material = this.materialYellow
   this.z.children[1].material = this.materialYellow
  } else {
   this.z.children[0].material = this.materialBlue
   this.z.children[1].material = this.materialBlue
  }

  if(raycaster.intersectObject(this.block, true).length > 0) {
   selected = true
   w = true
   this.block.material = this.materialYellow
  } else {
   this.block.material = this.materialWhite
  }

  return { selected, x, y, z, w }
}
